home *** CD-ROM | disk | FTP | other *** search
-
-
-
- DIRECTORY C Library Procedures DIRECTORY
-
-
-
- NNAAMMEE
- opendir, readdir, telldir, seekdir, rewinddir, closedir,
- dirfd - directory operations
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
- ##iinncclluuddee <<ssyyss//ddiirr..hh>>
-
- DDIIRR **ooppeennddiirr((ffiilleennaammee))
- cchhaarr **ffiilleennaammee;;
-
- ssttrruucctt ddiirreecctt **rreeaaddddiirr((ddiirrpp))
- DDIIRR **ddiirrpp;;
-
- lloonngg tteellllddiirr((ddiirrpp))
- DDIIRR **ddiirrpp;;
-
- sseeeekkddiirr((ddiirrpp,, lloocc))
- DDIIRR **ddiirrpp;;
- lloonngg lloocc;;
-
- rreewwiinnddddiirr((ddiirrpp))
- DDIIRR **ddiirrpp;;
-
- cclloosseeddiirr((ddiirrpp))
- DDIIRR **ddiirrpp;;
-
- ddiirrffdd((ddiirrpp))
- DDIIRR **ddiirrpp;;
-
- DDEESSCCRRIIPPTTIIOONN
- _O_p_e_n_d_i_r opens the directory named by _f_i_l_e_n_a_m_e and associates
- a _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m with it. _O_p_e_n_d_i_r returns a pointer to be
- used to identify the _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m in subsequent opera-
- tions. The pointer NNUULLLL is returned if _f_i_l_e_n_a_m_e cannot be
- accessed, or if it cannot _m_a_l_l_o_c(3) enough memory to hold
- the whole thing.
-
- _R_e_a_d_d_i_r returns a pointer to the next directory entry. It
- returns NNUULLLL upon reaching the end of the directory or
- detecting an invalid _s_e_e_k_d_i_r operation.
-
- _T_e_l_l_d_i_r returns the current location associated with the
- named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m.
-
- _S_e_e_k_d_i_r sets the position of the next _r_e_a_d_d_i_r operation on
- the _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m. The new position reverts to the one
- associated with the _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m when the _t_e_l_l_d_i_r opera-
- tion was performed. Values returned by _t_e_l_l_d_i_r are good
- only for the lifetime of the DIR pointer from which they are
- derived. If the directory is closed and then reopened, the
- _t_e_l_l_d_i_r value may be invalidated due to undetected directory
-
-
-
- Sprite v1.0 December 22, 1986 1
-
-
-
-
-
-
- DIRECTORY C Library Procedures DIRECTORY
-
-
-
- compaction. It is safe to use a previous _t_e_l_l_d_i_r value
- immediately after a call to _o_p_e_n_d_i_r and before any calls to
- _r_e_a_d_d_i_r.
-
- _R_e_w_i_n_d_d_i_r resets the position of the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m
- to the beginning of the directory.
-
- _C_l_o_s_e_d_i_r closes the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m and frees the
- structure associated with the DIR pointer.
-
- _D_i_r_f_d returns the integer file descriptor associated with
- the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m, see open(2).
-
- Sample code which searchs a directory for entry ``name'' is:
-
- len = strlen(name);
- dirp = opendir(".");
- for (dp = readdir(dirp); dp != NULL; dp =
- readdir(dirp))
- if (dp->d_namlen == len && !strcmp(dp->d_name,
- name)) {
- closedir(dirp);
- return FOUND;
- }
- closedir(dirp);
- return NOT_FOUND;
-
- SSEEEE AALLSSOO
- open(2), close(2), read(2), lseek(2), dir(5)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v1.0 December 22, 1986 2
-
-
-
-